package org.api.result.config;

import lombok.Getter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

@Configuration(proxyBeanMethods = false)
@ComponentScan("org.api.result")
public class EnableApiResultConfiguration {

    @Getter
    static String pageParameter = "page";

    @Getter
    static String sizeParameter = "pageSize";

    @Autowired
    public void set(ApplicationContext applicationContext) {
        EnableApiResultConfiguration.pageParameter = applicationContext.getEnvironment().getProperty("spring.data.web.pageable.page-parameter", "page");
        EnableApiResultConfiguration.sizeParameter = applicationContext.getEnvironment().getProperty("spring.data.web.pageable.size-parameter", "pageSize");
    }
}
